/**
 * 全排列
 * @param arr 
 */
function fullPermutation(arr: any[]){
    let result = [];
    if(arr.length == 1){
        result.push([arr[0]]);
        return result;
    }

  
    for(let i = 0, l = arr.length; i < l; i++){
        const temp = [...arr];
        const first = [arr[i]];
        temp.splice(i, 1);
        let newArr = fullPermutation(temp);
        for(let item of newArr){
           result.push([
               ...first,
               ...item
           ]);
        }
    }

    return result;
}


const result = fullPermutation([1,2,3,4,5,6]);

console.table(result); 
debugger;